<template>
  <div class="swiper-wrap">
    <swiper :options="swiperOption"
            v-if='showSwiper'>
      <!-- slides -->
      <swiper-slide v-for='item of list'
                    :key='item.id'>
        <img class="swiper-img"
             :src="item.imgUrl"
             :alt="item.id">
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination"
           slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: {
          el: '.swiper-pagination',
          bulletActiveClass: 'my-bullet-active'
        },
        loop: true
      }
    }
  },
  computed: {
    showSwiper () {
      return this.list.length
    }
  }
}
</script>
<style>
.my-bullet-active {
  opacity: 1;
  background: #fff;
}
</style>
<style lang='scss' scoped>
.swiper-img {
  width: 100%;
}
.swiper-wrap {
  width: 100%;
  height: 0;
  overflow: hidden;
  padding-bottom: 31.25%;
}
</style>
